package main

import (
	"fmt"
	"time"
)

func main() {
	//创建一个无缓冲队列的chan
	ch := make(chan int)
	go func() {
		for i := 1; i <= 5; i++ {
			time.Sleep(time.Millisecond)
			fmt.Println(i)
		}
		ch <- 0
	}()

	go func() {
		for i := 1; i <= 5; i++ {
			time.Sleep(time.Millisecond)
			fmt.Println(i * 10)
		}
		ch <- 0
	}()
	//循环两次读取chan的数据，没有数据则会等待
	//实现了类似WaitGroup的操作
	for i := 0; i < 2; i++ {
		<-ch
	}
}
